<?php

namespace app\admin\validate;

use think\Validate;

class Admin extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'username'  =>  'require',
        'email'     =>  'require|email|unique:admin',
        'password'    =>  'require|confirm|length:6,12',
        'password_confirm'  =>  'require|length:6,12',
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'username.require'  =>  '用户名不能为空',
        'email.require'     =>  '邮箱不能为空',
        'email.unique'      =>  '邮箱已存在',
        'email.email'       =>  '邮箱格式不正确',
        'password.require'    =>  '密码不能为空',
        'password.length'   =>  '密码长度在6~12位',
        'password_confirm.require'  =>  '重复密码不能为空',
        'password.confirm'  =>  '两次密码不一致'
    ];

    protected $scene = [
        'add'       =>  ['username','email','password','password_confirm'],
        'edit'      =>  ['username' => 'require','email' => 'require|email']
    ];
}
